/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * $Id: BehaviourData.hpp,v 1.8 2009-05-13 07:18:16 amaula Exp $
 *
 * \file
 * \brief MaCI - Behaviour interface data encoder / decoder
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 */
#ifndef _MACI_BEHAVIOURDATA_HPP_
#define _MACI_BEHAVIOURDATA_HPP_
#include "MaCIData.hpp"
#include "BehaviourTypes.hpp"
#include <stdio.h>
#include "owndebug.h"

namespace gim {
  namespace binbag{class CBinBag;}
}

namespace MaCI {
  namespace Behaviour {
    
    /** Data Encoder/Decoder for the Behaviour Interface.
     *
     * Contains the real protocol encoder/decoder for the MaCI-Behaviour
     * interface
     */
    class CBehaviourData : public MaCI::CMaCIData
    {
    public:
      /** Constructor for BehaviourData
       *
       */
      CBehaviourData(void);

      /** Destructor for CBehaviourData
       *
       */
      ~CBehaviourData();

      /** Copy constructor for BehaviourData. 
       *
       * The copy constructor duplicates the input object to maximum
       * depth (All containers are duplicated too). After a copy is
       * constructed, no dependencies to original Data element exist.
       *
       * @param[in] aBehaviourData Reference to CBehaviourData container to copy.
       */
      CBehaviourData(const CBehaviourData &aBehaviourData);

      /** Assignment operator for BehaviourData.
       *
       * The assignment operator duplicates the input object to
       * maximum depth (All containers are duplicated too). After a
       * copy is constructed, no dependencies to original Data element
       * exist.
       *
       * @param[in] aBehaviourData Reference to CBehaviourData container to copy.
       */
      CBehaviourData &operator=(const CBehaviourData &aBehaviourData);

      /** Decode a BinBag container as PositionData element.
       *
       */
      bool DecodeFrom(gim::binbag::CBinBag *aBinBag = NULL);
      
      /** Reset decoder/Encoder.
       *
       * Resets all fields, except leaves the current BinBag container
       * pointer intact.
       */
      void Reset();

      /**
       * Sets a TCommand structure to BehaviourData
       *
       * @param aCommand       Structure to add
       * @return               True if adding succeeded
       */
      bool SetCommand(const TCommand &aCommand);

      /**
       * Sets a TBehaviourControl structure to BehaviourData
       *
       * @param aControl       Structure to add
       * @return               True if adding succeeded
       */
      bool SetBehaviourControl(const TBehaviourControl &aControl);

      /**
       * Sets a TBehaviourControlSpeed structure to BehaviourData
       *
       * @param aControl       Structure to add
       * @return               True if adding succeeded
       */
      bool SetBehaviourControlSpeed(const TBehaviourControlSpeed &aControl);

      /**
       * Sets a TBehaviourInformation structure to BehaviourData
       *
       * @param aInfo          Structure to add
       * @return               True if adding succeeded
       */
      bool SetBehaviourInfo(const TBehaviourInformation &aInfo);


      /**
       * Sets a TBehaviourState structure to BehaviourData
       *
       * @param aInfo          Structure to add
       * @return               True if adding succeeded
       */
      bool SetBehaviourState(const TBehaviourState &aInfo);

      /**
       * Returns the command structure pointer set to BehaviourData
       *
       * @return               TCommand-structure pointer
       */
      const TCommand *GetCommand(void) const {
        return iCommandPtr;
      }

      /**
       * Returns the behaviour control structure pointer set to BehaviourData
       *
       * @return               TBehaviourControl-structure pointer
       */
      const TBehaviourControl *GetBehaviourControl(void) const {
        return iBehaviourControlPtr;
      }

      /**
       * Returns the behaviour control speed structure pointer set to BehaviourData
       *
       * @return               TBehaviourControl-structure pointer
       */
      const TBehaviourControlSpeed *GetBehaviourControlSpeed(void) const {
        return iBehaviourControlSpeedPtr;
      }

      /**
       * Returns the behaviour info structure pointer set to BehaviourData
       *
       * @return               TBehaviourInformation-structure pointer
       */
      const TBehaviourInformation *GetBehaviourInfo(void) const{
        return iBehaviourInfoPtr;
      }

      /**
       * Returns the behaviour state structure pointer set to BehaviourData
       *
       * @return               TBehaviourState-structure pointer
       */
      const TBehaviourState *GetBehaviourState(void) const{
        return iBehaviourStatePtr;
      }
      /**
       * Prints the contain of the BehaviourData
       *
       * @param level The debug print level
       */
      void Print(const int level) const;

    protected:
    private:
      const TCommand *iCommandPtr;
      const TBehaviourControl *iBehaviourControlPtr;
      const TBehaviourControlSpeed *iBehaviourControlSpeedPtr;
      const TBehaviourInformation *iBehaviourInfoPtr;
      const TBehaviourState *iBehaviourStatePtr;
    };
  }
}
#endif
